

package jetbrains.buildServer.server.graphql.model.connections.agentPool;

import graphql.execution.DataFetcherResult;
import graphql.relay.PageInfo;
import java.util.List;
import jetbrains.buildServer.server.graphql.model.Project;
import jetbrains.buildServer.server.graphql.model.connections.*;
import jetbrains.buildServer.serverSide.SProject;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class AgentPoolProjectsConnection implements ExtensibleConnection<Project, AgentPoolProjectsConnection.AgentPoolProjectsConnectionEdge> {
  @NotNull
  private final PaginatingConnection<SProject, Project, AgentPoolProjectsConnectionEdge> myDelegate;
  @Nullable
  private Integer myExcludedCount;

  public AgentPoolProjectsConnection(@NotNull List<SProject> data, @Nullable Integer excludedCount, @NotNull PaginationArguments paginationArguments) {
    myDelegate = new PaginatingConnection<>(data, AgentPoolProjectsConnectionEdge::new, paginationArguments);
    myExcludedCount = excludedCount;
  }

  public int getCount() {
    return myDelegate.getData().size();
  }

  @Nullable
  public Integer getExcludedCount() {
    return myExcludedCount;
  }

  @NotNull
  @Override
  public DataFetcherResult<List<AgentPoolProjectsConnectionEdge>> getEdges() {
    return myDelegate.getEdges();
  }

  @Nullable
  @Override
  public PageInfo getPageInfo() {
    return myDelegate.getPageInfo();
  }

  public class AgentPoolProjectsConnectionEdge extends LazyEdge<SProject, Project> {
    public AgentPoolProjectsConnectionEdge(@NotNull SProject data) {
      super(data, Project::new);
    }
  }
}